/*
 *  hihocoder.com
 *
 *  Category: Greed
 */

/*-------- Includes --------*/
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

/*-------- Defines --------*/


/*-------- Types --------*/


/*-------- Global Variables --------*/


/*-------- Function Prototypes --------*/


/*-------- Main Function --------*/
int main(int argc, char const *argv[])
{
    int N,  N2;
    int BJ, SH;
    int sum = 0;

    vector<int> v;

    cin >> N;

    N2 = N << 1;

    for (int i = 0; i < N2; ++i) {
        cin >> BJ >> SH;

        sum += BJ;
        v.push_back(BJ - SH);
    }

    sort(v.begin(), v.end());

    for (int i = 0; i < N; ++i) sum -= v[i];

    cout << sum << endl;

    return 0;
}

/*-------- Functions --------*/

